#!/usr/bin/env bash

PHP_VERSION=7.2.13

  mkdir ~/download \
  && cd ~/download \
  && wget http://hk2.php.net/distributions/php-$PHP_VERSION.tar.gz \
  && tar -zxf php-$PHP_VERSION.tar.gz \
  && cd php-$PHP_VERSION \
  && ./configure \
        --prefix=/usr/local/php \
        --with-config-file-path=/usr/local/php/etc/ \
        --with-config-file-scan-dir=/usr/local/php/conf.d/ \
        --enable-fpm \
        --enable-cgi \
        --with-fpm-user=nginx  \
        --with-fpm-group=nginx \
        --disable-phpdbg \
        --enable-mbstring \
        --enable-calendar \
        --with-xsl \
        --with-openssl \
        --enable-soap \
        --enable-zip \
        --enable-shmop \
        --enable-sockets \
        --with-gd \
        --with-freetype-dir=/usr/include/freetype2/freetype \
        --with-jpeg-dir \
        --with-png-dir \
        --with-xpm-dir \
        --with-xmlrpc \
        --enable-pcntl \
        --enable-intl \
        --with-mcrypt \
        --enable-sysvsem \
        --enable-sysvshm \
        --enable-sysvmsg \
        --enable-opcache \
        --with-iconv \
        --with-bz2 \
        --with-curl \
        --enable-mysqlnd \
        --with-mysqli=mysqlnd \
        --with-pdo-mysql=mysqlnd \
        --with-zlib \
        --with-gettext \
  && make \
  && make install \
  && cp ~/download/php-$PHP_VERSION/php.ini-production /usr/local/php/etc/php.ini \
  && cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf \
  && cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf \
  && rm -rf ~/download
  